import blue
import bluepy
import trinity
import uthread

class WodScene(bluepy.WrapBlueClass('trinity.WodScene')):
    __guid__ = 'graphicWrappers.WodScene'

    @staticmethod
    def Wrap(triObject, resPath):
        WodScene(triObject)
        triObject.city = trinity.WodCity()
        return triObject



    def AddAvatarToScene(self, avatar):
        self.city.AddAvatarToScene(avatar)



    def RemoveAvatarFromScene(self, avatar):
        self.city.RemoveAvatarFromScene(avatar)



    def AddBuildingToScene(self, building):
        self.city.AddBuildingToScene(building)



    def RemoveBuildingFromScene(self, building):
        self.city.RemoveBuildingFromScene(building)



    def AddPlaceableToScene(self, placeable):
        self.city.AddPlaceableToScene(placeable)



    def RemovePlaceableFromScene(self, placeable):
        self.city.RemovePlaceableFromScene(placeable)



    def AddLineSetToScene(self, lineSet):
        self.city.AddLineSetToScene(lineSet)



    def RemoveLineSetFromScene(self, lineSet):
        self.city.RemoveLineSetFromScene(lineSet)



    def AddCurveSetToScene(self, curveSet):
        self.city.curveSets.append(curveSet)



    def RemoveCurveSetFromScene(self, curveSet):
        self.city.curveSets.remove(curveSet)



    def Refresh(self):
        self.city.RebuildUmbraScene()



    def DelayedRefresh(self):
        if not getattr(self, '_delayedRefresh', False):
            self._delayedRefresh = True
            uthread.new(self._DelayedRefresh).context = 'WodScene::DelayedRefresh'



    def _DelayedRefresh(self):
        blue.synchro.Sleep(250)
        self.Refresh()
        self._delayedRefresh = False



    def RemoveSkyboxTexture(self):
        self.city.backgroundEffect = None



    def SetSkyboxTexture(self, texturePath):
        self.city.backgroundEffect = trinity.Tr2Effect()
        texture = trinity.TriTextureCubeParameter()
        texture.name = 'EnvMap1'
        texture.resourcePath = texturePath
        self.city.backgroundEffect.resources.append(texture)
        self.city.backgroundEffect.effectFilePath = 'res:/Graphics/Effect/Managed/Exterior/SpecialFX/EnvironmentCubemap.fx'




